<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>非枚举审核</title>
    <!-- CSS -->
    <jsp:include page="../include/headtag.jsp" />
    <!-- <link rel="stylesheet"
        href="http://fonts.googleapis.com/css?family=Roboto:400,100,300,500"> -->
    <link rel="stylesheet"
          href="assets/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="assets/css/form-elements.css">
    <link rel="stylesheet" href="assets/css/style.css">
    <%
        /********** 保存网站的基本路径 ***********/
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
                + path + "/";
        //将该路径地址缓存到 session中 ,例如：http://localhost:8090/tjnu_ssh_1128/
        session.setAttribute("mybasePath", basePath);
    %>
</head>
<body>
<jsp:include page="../include/head.jsp" />
<jsp:include page="../include/menu.jsp" />
<div id="page-wrapper" style="margin-top: 50px;">
    <div id="page-inner">
        <div class="text-left">
            <a href="/index">首页</a>&nbsp;&gt;&nbsp;<a href="/auditing" class="acts CurrChnlCls">编码审核</a>&nbsp;&gt;&nbsp;<a class="acts CurrChnlCls">待审核列表</a> &nbsp;&gt;&nbsp;<a class="acts CurrChnlCls">整体审核</a> &nbsp;&gt;&nbsp;<a class="acts CurrChnlCls">非枚举审核</a>
        </div>

        <div class="row">
            <div class="col-md-12">
                <h3 class="text-left">非枚举审核</h3>
                <div class="col-md-12">
                    <div class="nav navbar-nav navbar-right">
                        <a href="">非枚举审核</a>
                    </div>
                </div>
            </div>
        </div>
        <hr />
        <br />
        <div class="container-fluid">

<c:choose>
        <c:when test="${fn:length(nonEnums)==0}">
            <h3 align="center">Oops,该规则没有非枚举类型...</h3>
            <br><br><br>
        </c:when>
            <c:otherwise>
        <c:forEach var="nonEnum" items="${nonEnums }" varStatus="s">

            <form class="form-horizontal table-bordered" role="form">
                <fieldset>
                    <legend>非枚举码段${s.count}</legend>
                    <h5 align="left">基本信息</h5>
                    <br><br>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="seg_name${s.count}">码段名称</label>
                        <div class="col-sm-9">
                            <input class="form-control" type="text" id="seg_name${s.count}" value=${nonEnum.details} size="10" readonly/>
                        </div>
                    </div>
                    <br><br>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="seg_kind${s.count}">码段位置</label>
                        <div class="col-sm-9">
                            <input class="form-control" type="text" id="seg_kind${s.count}" size="10" value=${nonEnum.codeCodeId} readonly/>
                        </div>
                    </div>

                    <br><br>

                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="seg_bit${s.count}">值下限</label>
                        <div class="col-sm-4">
                            <input class="form-control" type="text" id="seg_bit${s.count}" size="10" value="${nonEnum.lowerLimit}" readonly/>
                        </div>

                        <label class="col-sm-1 control-label" for="seg_det${s.count}">值上限</label>
                        <div class="col-sm-4">
                            <input class="form-control" type="text" id="seg_det${s.count}" size="10" value="${nonEnum.upperLimit}" readonly/>
                        </div>
                    </div>

                    <br><br>
                    <hr style="margin:0px;background-color:#eee;height:0.5px;border:none;" />
                    <h5 align="left">非枚举审核</h5>

                    <div class="form-group">
                        <div class="form-horizontal">
                            <label class="col-sm-2 control-label" for="wdxing${s.count}">稳定性/合理性检验:</label>
                            <div class="col-lg-9">
                                <textarea id="wdxing${s.count}" class="form-control"
                                          style="resize: none;
                                      LINE-HEIGHT:18px;padding: 3px;width:100%;height:100px;max-width:100%;max-height: 100px;"></textarea>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                            <div class="form-horizontal">
                                <div class="col-lg-2 col-lg-push-3" >
                                    <input type=radio name="hlx_is_pass${s.count}"  style="zoom:150%;" value=1>
                                    <label for="hlx_pass${s.count}">通过</label>
                                </div>

                                <div class="col-lg-2 col-lg-push-6">
                                    <input type=radio name="hlx_is_pass${s.count}"  style="zoom:150%;" value=0>
                                    <label for="hlx_unpass${s.count}">不通过</label>
                                </div>
                            </div>
                    </div>

                    <br>

                    <div class="form-group">
                        <div class="form-horizontal">
                            <label class="col-sm-2 control-label" for="rongyuxing${s.count}">冗余性检验:</label>

                            <div class="col-lg-9">
                                <textarea id="rongyuxing${s.count}" class="form-control"
                                          style="resize: none;
                                      LINE-HEIGHT:18px;padding: 3px;width:100%;height:100px;max-width:100%;max-height: 100px;"></textarea>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="form-horizontal">
                            <div class="col-lg-2 col-lg-push-3" >
                                <input type=radio name="ryx_is_pass${s.count}"  style="zoom:150%;" value=1>
                                <label for="ryx_pass${s.count}">通过</label>
                            </div>

                            <div class="col-lg-2 col-lg-push-6">
                                <input type=radio name="ryx_is_pass${s.count}"  style="zoom:150%;" value=0>
                                <label for="ryx_unpass${s.count}">不通过</label>
                            </div>
                        </div>
                    </div>

                </fieldset>
            </form>


                <br>
                <br>

            <a id="clear" value="save" class="col-lg-3 btn btn-default btn-sm col-lg-push-3" onclick="mclear(${s.count})">清除</a>
            <a id="save" value="next" class="col-lg-3 btn btn-primary btn-sm col-lg-push-4" onclick="save(${s.count})">保存</a>

<%--            <div id="data">test</div>--%>
                <br><br><br>
                <hr style="border-top:1px dashed #0066CC;"/>
                <br>
                <br>
            </c:forEach>
            </c:otherwise>
</c:choose>
            <div class="row">
                <a  value="submit" class="col-lg-4 btn btn-info btn-sm col-lg-push-4" onclick="redir_to_bot()">下一步</a>
            </div>

                <br>
                <br>

        </div>


    </div>
    <!-- /. PAGE INNER  -->
</div>
<!-- /. PAGE WRAPPER  -->

</body>
<!-- Javascript -->
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/bootstrap/js/jquery.min.js"></script>
<script src="assets/js/jquery.backstretch.min.js"></script>

<script type="text/javascript">
    window.onload = function () {
        is_save = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
    }
</script>


<script type="text/javascript">
    function redir_to_bot() {
        for(var i =1 ;i <=${fn:length(nonEnums)};i++){
            if(is_save[i]==0){
                alert("请先保存码段"+i+"的相关审核操作!");
                return false;
            }
        }
        var record_id = ${record.codeRuleManageId};
        window.location.href = "/auditingBot?id="+record_id;
    }
</script>

<script type="text/javascript">

    function save(id){
        var heli_name = "hlx_is_pass"+id;
        var rongyu_name = "ryx_is_pass"+id;
        var heli = $(":radio[name='" +heli_name +"']:checked").val();
        var rongyu = $(":radio[name='" +rongyu_name +"']:checked").val();

        if(heli==null){
            alert("请选择码段"+id+"是否满足合理性!");
            return false;
        }

        if(rongyu==null){
            alert("请选择码段"+id+"是否满足冗余性!");
            return false;
        }

        if($("#wdxing"+id).val()==""){
            alert("请输入码段"+id+"的稳定性审核意见！");
            return false;
        }

        if($("#rongyuxing"+id).val()==""){
            alert("请输入码段"+id+"的冗余性审核意见！");
            return false;
        }


        var is_pass = 1;

        if(heli==1 && rongyu==1){
            is_pass=1;
        }
        else{
            is_pass=0;
        }

        is_save[id]=1;
        alert("保存成功！");

        var url = "/auditingMid";
        var params = {
            "id":0,
            "ruleId":${rule.codeRuleId},
            "segName":$("#seg_name"+id).val(),
            "wending":$("#wdxing"+id).val(),
            "rongyu":$("#rongyuxing"+id).val(),
            "isPass":is_pass
        };
        $.ajax({
            url:url,
            data:JSON.stringify(params),
            type:"post",
            success:function (resultData) {
                console.log("success");
            },
            dataType:"json",
            contentType: 'application/json',
        });
    }
</script>


<script type="text/javascript">
    function mclear(id){
        var heli_name = "hlx_is_pass"+id;
        var rongyu_name = "ryx_is_pass"+id;
        $(":radio[name='" +heli_name +"']:checked").attr("checked", false);
        $(":radio[name='" +rongyu_name +"']:checked").attr("checked", false);
        $("#wdxing"+id).val("");
        $("#rongyuxing"+id).val("");
        alert("清除成功！");
    }
</script>

</html>
